#ifndef DIR_INCLUDED
#define DIR_INCLUDED

#include <string.h>
#include <stdbool.h>

#define EMPTY_DIRECTORY_NAME ""
#define MAX_DIRECTORY_NAME 16

typedef uint16_t directory_index_t;
typedef struct {
	char directoryName[MAX_DIRECTORY_NAME + 1];
	directory_index_t parentDirectory;
} Directory;

void directory_initEmpty( Directory * dir )
{
	strcpy( dir->directoryName, EMPTY_DIRECTORY_NAME );
}

int directory_init( Directory * dir, const char * name, directory_index_t parent )
{
	if ( strlen( name ) > MAX_DIRECTORY_NAME || strcmp( name, EMPTY_DIRECTORY_NAME ) == 0 )
		return -1;

	memcpy( dir->directoryName, name, MAX_DIRECTORY_NAME + 1 );
	dir->parentDirectory = parent;

	return 0;
}

bool directory_isEmpty( const Directory * dir )
{
	return ( strcmp( dir->directoryName, EMPTY_DIRECTORY_NAME ) == 0 );
}

#endif
